package com.phone.client.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seventh.common.pojo.R;
import com.phone.client.mapper.InterMapper;
import com.phone.client.poji.entry.TbIntegrationHistory;
import com.phone.client.poji.vo.InterVo;
import com.phone.client.service.InterService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: clms-seventh
 * @description: InterService的实现
 * @author: 杨佳琪
 * @create: 2021-07-24 15:05
 **/
@ApiModel(value="积分记录的service的实现", description="积分记录的service的实现")
@Service
public class InterServiceImpl implements InterService {
    @Resource
    private InterMapper interMapper;

    @ApiModelProperty("分页查询")
    @Override
    public R findAllInterByPage(Integer currentPage, Integer pageSize, InterVo interVo) {
        Page<TbIntegrationHistory> page=new Page<>(currentPage,pageSize);
        QueryWrapper<TbIntegrationHistory> wrapper=new QueryWrapper<>();
        if (StringUtils.isNotEmpty(interVo.getCreateTime())){
            wrapper.like("create_time",interVo.getCreateTime());
        }
        if (StringUtils.isNotEmpty(interVo.getName())){
            wrapper.like("name",interVo.getName());
        }
        IPage<TbIntegrationHistory> page1=interMapper.findAllInterByPage(page,wrapper);
        return R.ok().put("records",page1.getRecords()).put("total",page1.getTotal());
    }

    @ApiModelProperty("删除")
    @Override
    public R deleteInter(Integer id) {
        int i=interMapper.deleteById(id);
        return R.ok();
    }

   /* @Override
    public R updateInter(TbIntegrationHistory tbIntegrationHistory) {
        interMapper.updateById(tbIntegrationHistory);
        return R.ok();
    }

    @Override
    public R insertInter(TbIntegrationHistory tbIntegrationHistory) {
        interMapper.insert(tbIntegrationHistory);
        return R.ok();
    }

    @Override
    public R findInterById(Integer id) {
        TbIntegrationHistory inter=interMapper.selectById(id);
        return R.ok().put("inter",inter);
    }*/
}
